//
//  RootTabBarController.swift
//  XMGTV-ls
//
//  Created by 中创 on 2020/4/27.
//  Copyright © 2020 LS. All rights reserved.
//

import UIKit

class RootTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setupUI()
        UITabBar.appearance().tintColor = UIColor(r: 202, g: 155, b: 104)
    }

}

extension RootTabBarController{
    fileprivate func setupUI(){
        addChildVC(viewController: HomeViewController(), title: "直播", img:"live-n", selectedImg:"live-p")
        addChildVC(viewController: RankViewController(), title: "排行", img:"ranking-n", selectedImg: "ranking-p")
        addChildVC(viewController: DiscoverViewController(), title: "发现", img:"found-n", selectedImg: "found-p")
        addChildVC(viewController: ProfileViewController(), title: "我的", img:"mine-n", selectedImg: "mine-p")
    }
    
    fileprivate func addChildVC(viewController:UIViewController, title:String, img:String, selectedImg:String){
        let nav = RootNavigationController(rootViewController: viewController)
        viewController.tabBarItem.title = title
        viewController.tabBarItem.image = UIImage(named: img)
        viewController.tabBarItem.selectedImage = UIImage(named: selectedImg)
        addChild(nav)
    }
}
